package com.wzl.common.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 多线程配置类
 */
@Configuration
public class ThreadPoolExecutorConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {

        ThreadPoolExecutor executor = new ThreadPoolExecutor(10,
                                                            12,
                                                            5,
                                                            TimeUnit.SECONDS,
                                                            new ArrayBlockingQueue<>(100));
        executor.allowCoreThreadTimeOut(true);
        return executor;

    }
}
